﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Your UK impressions</title>
<link href="css/popup.css" rel="stylesheet" type="text/css" />
    <script src="js/jquery-1.3.2.js" type="text/javascript"></script>
    <script type="text/javascript" >
        var EngCode = 1033;
        var checknum = 0;
        function matchem(obj) {


            if (obj.checked) {

                if (checknum == 3) {
                    obj.checked = false;
                    alert("Most can only choose three");

                }
                else {
                    checknum++;
                }
            }
            else {
                checknum--;
            }



        }
        //2填充投票选项
        function fill(keywordArray) {
            var sT = "<li><span  ><input name='keyGp' type='checkbox' onclick='matchem(this)' ";
            var eN = "</span></li>";
            var lastHtml = "";
            var newdata = keywordArray.split('|');
            for (var i = 0; i < newdata.length && i < 11; i++) {


                lastHtml += sT + "value='" + newdata[i] + "'/></span><span style='color:#fff'> " + newdata[i] + eN;


            }


            document.getElementById("keyZone").innerHTML = lastHtml;

        }
        //1请求已发布的关键字选项
        function LoadPost() {


            $.post(
        "Vote.aspx", { code: EngCode },
         function (data) {


             if (data != "0") {
                 fill(data)

             } else {
                 alert("Net  error");
             }


         }
        );





        }
        //字数检测
        function FontSum() {
            alert("helo");
        }
        //发送调查结果
        function sendRes() {
            
            var ches = document.getElementsByName("keyGp");

            var paid = null;


            var chstr = "";
            for (var i = 0; i < ches.length; i++) {


                if (ches[i].checked) {

                    chstr += ches[i].value + "|";

                }

            }

            if ($("#votex").val() == "Less than 5 words.") {

                $("#votex").val("");
            }

            if ($("#votex").val() != "" || chstr != "") 
          {

                    var ches1 = chstr.split('|');
                    if (ches1.length == 2) {
                        paid = { "1": ches1[0], code1: EngCode, x: $("#votex").val() };
                    }
                    if (ches1.length == 3) {
                        paid = { "1": ches1[0], "2": ches1[1], code1: EngCode, x: $("#votex").val() };
                    }
                    if (ches1.length == 4) {
                        paid = { "1": ches1[0], "2": ches1[1], "3": ches1[2], code1: EngCode, x: $("#votex").val() };
                    }
                    $.post(
                     "Vote.aspx", paid, function (data) {
                    window.location = "result.html";
                     }
                     );
                }
                else {

                    alert(" Please enter  the UK impressions.");
                }

            }
     






    </script>
</head>
<body onload="LoadPost()">
<div id="vote">
	<div class="close"><a href="#" onclick="parent.tb_remove();"><img src="images/icon_vote_close.gif" alt="" /></a></div>
    <div class="content">
    	<form >
    	<div class="title">Please select from the list below (Choose up to three)</div>
        <div class="vote">
        	<ul id="keyZone">

            </ul>
        </div>
        <dl>
            <dt>Please share your own impressions:</dt>
            <script>
                var txt = "";
                function checkin() {


                   
                    var sp = $("#votex").val().split(" ").length;
                    if (sp==6||sp>6) {
                       
                        if (txt == "") {
                            txt = $("#votex").val();
                        }
                      
                        $("#votex").val(txt);
                        alert("Less than 5 words.");
                        

                    }
                    
//                    if ($("#votex").val().split('Up to 5 characters').length > 5)
//                   { 
//                alert('');
//                   }
                }
            </script>
            <dd><input name="" id="votex" value="Less than 5 words." type="text"    onkeyup="checkin()" onfocus="if(this.value=='Less than 5 words.'){this.value=''}" /></dd>
        </dl>
        <div class="votebtn"><input name="" id="" type="button" onclick="sendRes()" value="" /></div>
        </form>
    </div>
</div>
</body>
</html>
